package com.mickey.service.Imp;

import com.mickey.dao.UserDao;
import com.mickey.domain.User;
import com.mickey.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class UserServiceImp implements UserService {

    @Autowired
    private UserDao userDao;
    @Override
    public User getUserById(int id) {
        return userDao.getById(id);
    }

    @Override
    @Transactional
    public User tx() {
        User u1 = new User();
        u1.setId(2);
        u1.setName("22222");
        User u2 = new User();
        u2.setId(3);
        u2.setName("333333");
        userDao.insert(u1);
        userDao.insert(u2);
        return u2;
    }
}
